

def getConfKey(path, configKey):
    # 初始化 access_url 和 access_key 变量
    return_key = ""

    try:
        # 打开当前目录下的 conf.txt 文件
        with open(path, "r", encoding="utf-8") as file:
            # 逐行读取文件内容
            for line in file:
                # 去除行首尾的空白字符
                line = line.strip()
                # 检查是否包含 "=" 符号
                if "=" in line:
                    # 分割键值对
                    key, value = line.split("=", 1)
                    # 去除键和值首尾的空白字符
                    key = key.strip()
                    value = value.strip()
                    # 去除值两端的引号
                    if value.startswith('"') and value.endswith('"'):
                        value = value[1:-1]
                    # 根据键将值赋给相应的变量
                    if key == configKey:
                        return_key = value
                        break

    except FileNotFoundError:
        print("未找到 conf.txt 文件。")
    except Exception as e:
        print(f"发生错误: {e}")
        
    # print(f"返回的值是: {return_key}")
    return return_key